<?php
namespace app\admin\controller;

use think\Db;
use think\facade\Session;
use think\Request;
use think\Controller;

class Login extends Controller
{
    public function _initialize()
    {
            parent::_initialize();
    }
    public function doLogin()
    {
        $username = $this->request->post('username');
        $password = $this->request->post('password');
        $data = Db::table('nx_admin_user')
            ->where([
                'loginid'=>$username,
                'password'=>md5($password),
                'delstatus'=>1
            ])->find();
        if($data){
            $adminuser = [
                'userid'=>$data['id'],
                'username'=>$data['username'],
            ];
            Session::set('adminuser',$adminuser);
            return 1;
        }else{
            return 0;
        }
    }
}
